import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.nio.charset.StandardCharsets;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

public class SuperSpider {
    static Scanner sc = new Scanner(System.in);
    public static void Baidu(){
        System.getProperties().setProperty("webdriver.chrome.driver", "chromedriver.exe");
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setHeadless(false);
        WebDriver chrome = new ChromeDriver(chromeOptions);
        System.out.println("目标百度,全力爬取");
        System.out.println("请输入要搜索的内容:");
        String urls=java.net.URLEncoder.encode(sc.next(), StandardCharsets.UTF_8);
        chrome.get("https://image.baidu.com/search/index?tn=baiduimage&word="+urls);
//        chrome.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        System.out.println("请输入要下载的图片数量等级,1等级大约20张图片");
        int  n =sc.nextInt();
        Thread t = new Baidu_supic(chrome,n);
        t.start();
    }
}
